package com.movies.controller.adminPacket;

import com.movies.pojo.User;
import com.movies.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Map;

@Controller
public class LogoutController {
    @Autowired
    UserService userService;

    @RequestMapping("/logout")
    public String toLogout(HttpSession session){
        Map map = (Map) session.getAttribute("map");
        System.out.println(map.get("admin"));
        map.put("admin",null);
        System.out.println(map.get("admin"));
        return "redirect:/";
    }
    @RequestMapping("/userLogout")
    public String userLogout(HttpSession session) {
        Map map = (Map) session.getAttribute("map");
        System.out.println(map.get("admin"));
        map.put("user",null);
        return "redirect:/";
    }

    @RequestMapping("/adduser1")
    public String adduser1(User user){
        System.out.println("进入添加用户界面=====》》");
        return "/adduser1";
    }
    @RequestMapping("/addUser1")
    public String addUser1(User user) {
        boolean save = userService.save(user);
        System.out.println("添加========>");
        return "redirect:/";
    }
}